package ru.budget.mobile.ui.navigation

import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import org.koin.androidx.compose.koinViewModel
import ru.budget.mobile.ui.base.BudgetViewModel
import ru.budget.mobile.ui.main.MainScreen
import ru.budget.mobile.ui.transactions.TransactionScreen

private val budgetViewModel @Composable get() = koinViewModel<BudgetViewModel>()

@Composable
fun NavigationGraph(controller: NavHostController) =
    NavHost(
        navController = controller,
        startDestination = "main",
        builder = {
            composable(
                "main",
                content = { MainScreen(viewModel = budgetViewModel) }
            )
            composable(
                "transactions",
                content = {
                    val state = budgetViewModel.stateFlow.collectAsState().value
                    TransactionScreen(budgetState = state)
                }
            )
        }
    )
